import * as THREE from "three";

export interface ShapeParams {
    [key: string]: number | string;
}

// 发射位置类型
export enum EmissionType {
    VOLUME = 'volume',     // 从体积内发射
    SURFACE = 'surface',   // 从表面发射
    VERTICES = 'vertices', // 从顶点发射
    EDGES = 'edges'        // 从边发射
}

export abstract class Shape {
    protected origin: THREE.Vector3;
    protected params: ShapeParams;
    protected geometry?: THREE.BufferGeometry; // 用于支持 BufferGeometry
    protected emissionType: EmissionType;

    constructor(origin: THREE.Vector3, params: ShapeParams = {}, geometry?: THREE.BufferGeometry) {
        this.origin = origin;
        this.params = params;
        this.geometry = geometry;
        this.emissionType = params.emissionType as EmissionType || EmissionType.SURFACE;
    }

    abstract getRandomPosition(): THREE.Vector3;
    abstract getRandomNormal(): THREE.Vector3;
    
    // 根据位置获取法向量（用于 BufferGeometry）
    abstract getNormalAtPosition?(position: THREE.Vector3): THREE.Vector3;
    
    // 设置几何体（用于动态更换 BufferGeometry）
    setGeometry(geometry: THREE.BufferGeometry) {
        this.geometry = geometry;
    }
}
